//////#include<iostream>
//////#include<cstdlib>
//////const int N = 1e6 + 10;
//////typedef long long ll;
//////ll grade[N], point[N];
//////using namespace std;
//////int main()
//////{
//////	ll n, m;cin >> n >> m;
//////	for (int i = 1; i <= n; i++)
//////	{
//////		cin >> grade[i];
//////	}
//////	for (int i = 1; i <= m; i++)
//////	{
//////		cin >> point[i];
//////	}
//////	ll ret = 1e7, ans = 0,sum = 0;
//////	for (int i = 1; i <= m; i++)
//////	{
//////		ret = 1e9;
//////		for (int j = 1; j <= n; j++)
//////		{
//////			ll s = point[i] - grade[j];
//////
//////			ret = min(abs(ret), abs(s));
//////		}
//////		sum += ret;
//////	}
//////	cout << sum;
//////	return 0;
//////}
////#include<iostream>
////#include<cstdlib>
////#include<algorithm>
////const int N = 1e6 + 10;
////typedef long long ll;
////ll a[N], b[N], p = 1;
////using namespace std;
////int main()
////{
////	int m, n;cin >> m >> n;
////	for (int i = 1; i <= m; i++)
////	{
////		cin >> a[i];
////	}
////	for (int i = 1; i <= n; i++)
////	{
////		cin >> b[i];
////	}
////	sort(a + 1, a + 1 + m);
////	sort(b + 1, b + 1 + n);
////	p = 1;
////	ll sum = 0;
////		for (int i = 1; i <= n; i++)
////		{
////			ll ret = 1e9;
////			while (p != m)
////			{
////				ll t = abs(a[p]) - abs(a[i]);
////				if (t < ret)
////				{
////					sum += b[i] - a[p];
////					break;
////				}ll ret = min(ret, abs(a[p]) - abs(b[i]));
////			
////				p++;
////			}
////		}
////		cout << sum << endl;
////	return 0;
////}
//#include<iostream>
//#include<vector>
//#include<set>
//#include<algorithm>
//using namespace std;
//const int N = 1e6 + 10;
//typedef long long ll;
//int INF = 1e8 + 10;
//ll a[N], b[N];
//int main()
//{
//	multiset<ll> mp;
//	int n, m;cin >> n >> m;
//	mp.insert(INF);
//	for (int i = 1; i <= n; i++)
//	{
//		cin >> a[i];
//		mp.insert(a[i]);
//	}
//	for (int i = 1; i <= m; i++)
//	{
//		cin >> b[i];
//	}ll sum = 0;
//	for (int i = 1; i <= n; i++)
//	{
//		auto p1 = mp.lower_bound(b[i]);
//		if (*(p1 - 1) == INF) sum += *p1;
//		else {
//			ll p2 = min(*p1, *(p1 - 1));
//			sum += p2;
//		}
//	}
//	cout << sum << endl;
//	return 0;
//}
//#include<iostream>
//#include<algorithm>
//#include<vector>
//using namespace std;
//int main()
//{
//	vector<int> mp;mp.push_back(9);mp.push_back(1);
//	/*for (int i = 1; i <= 3; i++)
//	{
//		mp.push_back(i);
//	}*/
//	auto p = lower_bound(mp.begin(), mp.end(), 9);
//	for (auto v : mp)
//	{
//		cout << v << ' ';
//	}
//	cout << endl;
//	//auto p1 = lower_bound(mp.begin(), mp.end(), 9);
//	//auto p2 = lower_bound(mp.begin(), mp.end(), 1);
//	//auto p3 = lower_bound(mp.begin(), mp.end(), 3);
//	auto p4 = lower_bound(mp.begin(), mp.end(), 9);
//	//auto p5 = mp.begin();
//	cout << *p4;
//	return 0;
//}
//#include<iostream>
//#include<cstdlib>
//#include<algorithm>
//typedef long long ll;
//const int N = 1e6 + 10;
//ll a[N],b[N];
//using namespace std;
//int main()
//{
//	int m, n;cin >> m >> n;
//	for (int i = 1; i <= m; i++)
//	{
//		cin >> a[i];
//	}
//	sort(a + 1, a + 1 + n);ll sum = 0;
//	a[0] = -1e8;
//	for (int i = 1; i <= n; i++)
//	{
//		cin >> b[i];
//		ll left = 1, right = n;
//		while (left < right)
//		{
//			ll mid = (right + left) / 2;
//			if (a[mid] >= b[i]) right = mid;
//			else left = mid + 1;
//		}
//		ll ret = min(abs(a[left] - b[i]), abs(a[left - 1]) - b[i]);
//		sum += ret;
//	}
//	cout << sum;
//	return 0;
//}
#include<iostream>
#include<algorithm>
typedef long long ll;
const int N = 1e6 + 10;
ll a[N], b[N];
using namespace std;
int main()
{
	int m, n;cin >> m >> n;ll sum = 0;
	for (int i = 1; i <= m; i++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + 1 + m);
	a[0] = -1e8;
	for (int i = 1; i <= n; i++)
	{
		cin >> b[i];
			int left = 1, right = m;
			while (left < right)
			{
				int mid = (right + left) / 2;
				if (a[mid] >= b[i]) right = mid;
				else left = mid + 1;
			}
			sum += min(abs(a[left - 1] - b[i]),abs( a[left] - b[i]));
	}
	cout << sum;
	return 0;
}